package cn.yunhe.biz;

import cn.yunhe.exception.OutOfStockException;
import lombok.Data;
import org.springframework.stereotype.Component;


@Component
public class PhoneBizImpl implements PhoneBiz {
    int num;

    @Override
    public void butPhone(int num) {
        System.out.println("买了"+num+"部手机");
        this.num=num;
    }

    @Override
    public void salePhone(int num) throws OutOfStockException {

        if(this.num<num){
            throw new OutOfStockException("库存需要"+num+"部"+"现在只有"+this.num+"部");
        } System.out.println("销售了"+num+"部手机");
    }
}
